#pragma once
#include <iostream>
#include <pthread.h>
#include <unistd.h>

namespace mycond
{
    class Cond
    {
    public:
        Cond()
        {
            pthread_cond_init(&_cond, nullptr);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
        // pthread_cond_wait()
        void Wait(pthread_mutex_t* pmutex)
        {
            pthread_cond_wait(&_cond, pmutex);
        }
        void Signal()
        {
            pthread_cond_signal(&_cond);
        }
        void Broadcast()
        {
            pthread_cond_broadcast(&_cond);
        }

    private:
        pthread_cond_t _cond;
    };

}